package variabilitysmelldetection.measurement.measures.method;

import java.util.List;

import variabilitysmelldetection.measurement.measures.component.LinesOfCode;
import variabilitysmelldetection.measurement.models.ComponentItem;
import variabilitysmelldetection.measurement.models.MethodItem;


public class MethodLinesOfCode extends LinesOfCode {

	public MethodLinesOfCode() {
		super("Method's Lines of Code", "MLoC");
	}

	@Override
	public void measure(List<ComponentItem> items) {
		for (ComponentItem classe : items) {
			measure(classe);
		}
	}	

	private void measure(ComponentItem componentItem) {
		double value = 0d;
		List<MethodItem> methods;

		methods = componentItem.getMethods();
		for (MethodItem m : methods) {
			value = calculateLines(m.getSource());

			MethodLinesOfCode methodLinesOfCode = new MethodLinesOfCode();
			methodLinesOfCode.setValue(value);
			m.addMeasure(methodLinesOfCode);
		}
	}
}